package com.shihan._02_juc_concurrent_utils._02_sync_tools.reentrantlock;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @Description
 * @Author shihan
 * @Date 2021/8/22 10:47
 * @Version 1.0
 */
public class MyThread01 implements Runnable {

    private final Lock lock = new ReentrantLock();

    @Override
    public void run() {
        lock.lock();
        System.out.println(Thread.currentThread().getName() + "：开始执行...");
        try {
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName() + "：执行结束...");
        lock.unlock();
    }
}
